#%%
from qutip.qip.operations import gate_sequence_product
from qutip.qip.circuit import QubitCircuit
import numpy as np

#%%
from qutip.qip.device import CircularSpinChain, LinearSpinChain
from qutip.qip.noise import RandomNoise

#%%
N = 3
qc = QubitCircuit(N)
qc.add_gate('CNOT', targets=[0], controls=[2])
gate_sequence_product(qc.propagators())
# %%
p1 = CircularSpinChain(N, correct_global_phase=True)
U_list = p1.run(qc)
U_physical = gate_sequence_product(U_list)
U_physical.tidyup(atol=1e-5)
# %%
p2=LinearSpinChain(N, correct_global_phase=True)
U_list=p2.run(qc)
U_physical=gate_sequence_product(U_list)
U_physical.tidyup(atol=1e-5)